package com.one.consumer.reserve.ui.binder;

import android.support.annotation.NonNull;
import android.view.View;
import android.widget.ImageView;

import com.one.common.manager.imageloader.ILoader;
import com.one.common.manager.imageloader.LoaderManager;
import com.one.common.model.http.NetConstant;
import com.one.common.view.multitytype.adapter.BaseItemBinder;
import com.one.common.view.multitytype.adapter.BaseViewHolderMulti;
import com.one.consumer.R;
import com.one.consumer.reserve.model.item.CaseItem;
import com.one.consumer.reserve.model.item.ProgramItem;

/**
 * author ：zhulunjun
 * email  ：zhulunjun@qq.com
 * date   ：2018/10/21 下午10:12
 * description ：户型选择->方案选择
 **/
public class ProgramBinder extends BaseItemBinder<ProgramItem> {
    public ProgramBinder(OnProgramClick onCaseClick) {
        super(R.layout.item_case);
        this.onProgramClick = onCaseClick;
    }

    @Override
    protected void bindView(@NonNull BaseViewHolderMulti holder, @NonNull ProgramItem item) {
        ImageView imageView = holder.getView(R.id.iv_bg);
        ILoader.Options options = ILoader.Options.roundOptions(8);
        options.setCenterCrop(true);
        options.setBlur(true);
        LoaderManager.getLoader().loadNet(imageView, NetConstant.IMG_HOST + item.getProgramme_img(),
                options);
        holder.setText(R.id.tv_name, item.getProgramme_name());
        holder.getView(R.id.rl_case).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(onProgramClick !=null){
                    onProgramClick.programClick(item);
                }
            }
        });
    }

    private OnProgramClick onProgramClick;

    public OnProgramClick getOnProgramClick() {
        return onProgramClick;
    }

    public void setOnCaseClick(OnProgramClick onProgramClick) {
        this.onProgramClick = onProgramClick;
    }

    public interface OnProgramClick{
        void programClick(ProgramItem item);
    }
}
